<template>
  <div class="main">
    <div class="header-card">
      <div class="uc-header">
        <div class="back" @click="$router.back()">
          <img src="@/assets/img/3.png" />
        </div>
        <div class="popup-" style="color: white">{{ $t("lisUlang") }}</div>
      </div>
    </div>
    <div class="list">
      <div class="fb-item">
        <div class="fb-inputbox">
          <!-- <div class="iconbox">
            <i class="van-icon van-icon-search" style="font-size: 18px"></i>
          </div> -->
          <input
            type="text"
            v-model="recharge.account_name"
            maxlength="30"
            @keydown.enter="handleSearch()"
            :placeholder="accountNamePlaceholder"
          />
        </div>
      </div>
      <div class="fb-item">
        <div class="fb-inputbox">
          <!-- <div class="iconbox">
            <i class="van-icon van-icon-search" style="font-size: 18px"></i>
          </div> -->
          <input
            type="text"
            v-model="recharge.amount"
            maxlength="30"
            @keydown.enter="handleSearch()"
            placeholder="Masukkan Jumlah Isi Ulang"
          />
        </div>
      </div>
    </div>
    <div class="ulang">
      <div @click="handleUlang">{{ $t("lsiUlang") }}</div>
    </div>
    <div class="my-container"></div>
    <van-popup v-model="confirm" round>
      <div class="uapopup">
        <div class="recharge">
          <div>{{ $t("AkunIsiUlang") }}</div>
          <div>{{ recharge.account_name }}</div>
        </div>
        <div class="recharge">
          <div>{{ $t("JumlahIsiUlang") }}</div>
          <div>{{ recharge.amount }}</div>
        </div>
        <div class="recharge">
          <div>{{ $t("MendapatkanBerlian") }}</div>
          <div class="flex">
            <!-- <img class="w-4 h-4 mr-1" src="../../assets/img/diamondd.png" /> -->
            {{ recharge.amount }} {{ $t("USD") }}
          </div>
        </div>
        <div class="text">
          {{ $t("AgenLsiTips") }}
        </div>
        <div class="footer">
          <van-button class="btn" color="#969696" @click="closePopup">{{
            $t("Batal")
          }}</van-button>
          <van-button class="btn" color="#7eb24d" @click="submitRecharge">{{
            $t("OK")
          }}</van-button>
        </div>
      </div>
    </van-popup>
    <van-popup v-model="tipShow" round>
      <div class="uapopup">
        <div class="success">{{ $t("IsiUlangBerhasil") }}</div>
        <div class="successFooter">
          <van-button
            class="successBtn"
            color="#7eb24d"
            @click="closeTipShow"
            >{{ $t("OK") }}</van-button
          >
        </div>
      </div>
    </van-popup>
  </div>
</template>
<script>
import { Toast } from "vant";
import { httpAgentRecharge } from "@/http/api";
export default {
  name: "ucenter",
  data() {
    return {
      recharge: {
        // 账号
        account_name: "",
        // 金额
        amount: "",
      },
      confirm: false,
      tipShow: false,
      Tanggal: "",
      choose: "",
      show: false,
      feedBackMsg: "",
      feedBackFlag: false,
      background: localStorage.getItem("bgck"),
    };
  },
  methods: {
    handleCopy(title) {
      // showToast("Success");
      Toast(title + " berhasil disalin");
    },
    handleAgen() {
      this.$router.push("/agent");
    },
    handleDetail() {
      console.log("handleDetail");
    },
    handleSearch() {
      console.log("handleSearch");
    },
    handleSelect() {
      console.log("handleSelect");
      this.show = true;
    },
    getContainer() {
      return document.querySelector(".my-container");
    },
    handleUlang() {
      this.confirm = true;
    },
    closePopup() {
      this.confirm = false;
    },
    async submitRecharge() {
      const res = await httpAgentRecharge(this.recharge);
      if (res.code == 0) {
        this.confirm = false;
        this.tipShow = true;
      } else {
        this.$Toast.fail(res.message);
      }
    },
    closeTipShow() {
      this.tipShow = false;
    },
  },
};
</script>
<style lang="less" scoped>
// * {
//   font-weight: 400;
//   color: white;
// }
@import url("./ucenter-common.less");
.modal {
  width: 80vw;
  height: 300px;
  min-height: 100px;
  padding: 30px;
  background: #c86c5f;
  &-title {
    color: #fff;
    font-size: 40px;
    text-align: center;
    padding-top: 30px;
  }
}
.main {
  .uapopup {
    width: 80vw;
    padding: 30px;
    background: #c86c5f;
    & > div {
      margin-bottom: 20px;
      color: #fff;
      font-size: 26px;
      & > div {
        width: 50%;
      }
    }

    .recharge div {
      color: #f4dad4;
      margin-bottom: 20px;
      font-size: 24px;
    }
    .text {
      line-height: 40px;
    }
    .footer {
      display: flex;
      justify-content: space-between;
      padding: 0 20px;
      .btn {
        width: 200px;
        height: 60px;
        border-radius: 10px;
      }
    }
    .success {
      text-align: center;
      font-size: 40px;
      padding: 20px;
    }
    .ulang {
      position: absolute;
    }
    .successFooter {
      display: flex;
      justify-content: center;
      padding: 0 20px;
      .successBtn {
        width: 200px;
        height: 60px;
        border-radius: 10px;
      }
    }
  }
}

.flex {
  display: flex;
}
.justify-between {
  justify-content: space-between;
}
.mr-20px {
  margin-right: 20px;
}
.pb-20px {
  padding-bottom: 20px;
}
.search-bar {
  display: flex;
  justify-content: space-between;
  margin: 0 20px;
  margin-bottom: 20px;
}
.content-box {
  margin-bottom: 20px;
}
.fb-item {
  width: 100%;
  padding: 8px;

  .fb-inputbox {
    color: #c86c5f;
    display: flex;
    width: 100%;
    background: #fff3e2;
    border-radius: 10px;
    display: flex;
    align-items: center;
    border: 2px solid transparent;
    transition: all 0.25s;
    padding: 12px;
    .iconbox {
      color: #c86c5f;
      width: 50px;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      user-select: none;
      flex-shrink: 0;

      img {
        width: 48px;
        height: 48px;
      }
    }

    input {
      flex: 1;
      height: 100%;
      background: transparent;
      border: none;
      outline: none;
      font-size: 30px;
      padding-right: 40px;

      &::-webkit-input-placeholder {
        color: #c86c5f;
      }
    }

    &.active {
      border: 2px solid #dcbc9b;
      background: #c86c5f;
    }

    &.error {
      border: 2px solid rgba(235, 63, 63, 1);
      background: #c86c5f;
    }
  }

  ::v-deep .van-dropdown-menu {
    width: 100%;

    .van-dropdown-menu__bar {
      background: transparent;
      box-shadow: none;

      .van-dropdown-menu__item {
        justify-content: flex-start;
      }

      .van-dropdown-menu__title {
        color: #c86c5f;
        font-size: 30px;
        padding: 0;
        width: 100%;
        display: block;

        &::after {
          right: 24px;
        }
      }
    }

    .van-dropdown-item__option--active {
      color: #c86c5f;

      .van-dropdown-item__icon {
        color: #c86c5f;
      }
    }
  }
}
.fb-items {
  width: 100%;

  .fb-inputbox {
    color: #c86c5f;
    display: flex;
    width: 100%;
    height: 80px;
    background: #fff3e2;
    border-radius: 10px;
    display: flex;
    align-items: center;
    border: 2px solid transparent;
    transition: all 0.25s;

    .iconbox {
      color: #c86c5f;
      width: 50px;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      user-select: none;
      flex-shrink: 0;

      img {
        width: 48px;
        height: 48px;
      }
    }

    input {
      flex: 1;
      height: 100%;
      background: transparent;
      border: none;
      outline: none;
      font-size: 30px;
      padding-right: 40px;

      &::-webkit-input-placeholder {
        color: #c86c5f;
      }
    }

    &.active {
      border: 2px solid #dcbc9b;
      background: #c86c5f;
    }

    &.error {
      border: 2px solid rgba(235, 63, 63, 1);
      background: #c86c5f;
    }
  }

  ::v-deep .van-dropdown-menu {
    width: 100%;

    .van-dropdown-menu__bar {
      background: transparent;
      box-shadow: none;

      .van-dropdown-menu__item {
        justify-content: flex-start;
      }

      .van-dropdown-menu__title {
        color: #c86c5f;
        font-size: 30px;
        padding: 0;
        width: 100%;
        display: block;

        &::after {
          right: 24px;
        }
      }
    }

    .van-dropdown-item__option--active {
      color: #c86c5f;

      .van-dropdown-item__icon {
        color: #c86c5f;
      }
    }
  }
}
.uc-header .back {
  height: initial;
}
.header-card {
  padding-bottom: 20px;
}
.list {
  margin-top: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid #fff;
}
.content {
  margin: 20px 0;
  &-box {
    margin: 0 20px 20px;
    padding: 20px;
    background: rgb(255, 243, 226);
    border-radius: 20px;
    &-text {
      line-height: 1.6;
      color: rgb(200, 108, 95);
      display: flex;
      justify-content: space-between;
      > div {
        color: rgb(200, 108, 95);
      }
    }
  }
  &-text {
    display: flex;
    justify-content: space-between;
    margin: 0 20px;
    line-height: 1.6;
    color: #fff;
  }
}
.mb-20px {
  margin-bottom: 20px;
}
.ulang {
  top: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  position: absolute;
  > div {
    width: 80vw;
    height: 80px;
    background: rgb(148, 195, 98);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #fff;
    position: fixed;
  }
}
</style>
